package com.mapull.primitive;

/**
 * @author Mapull
 * @date 2024-04-11
 */
public class SimpleBool {

    public static void main(String[] args) {
        Boolean bool = Boolean.TRUE;
        boolean b = bool.booleanValue();

        Boolean bool2 = new Boolean("true");
        boolean c = bool2.booleanValue();
        System.out.println(b == c);
    }

    public static void main9(String[] args) {
        // 解析 true 字符串
        boolean bool1 = Boolean.valueOf("true");
        boolean bool2 = Boolean.valueOf("True");
        boolean bool3 = Boolean.valueOf("TRUE");
        // 解析不是 true 字符串
        boolean bool4 = Boolean.valueOf("False");
        boolean bool5 = Boolean.valueOf("1");
        boolean bool6 = Boolean.valueOf("Java");
        // 解析空字符串
        boolean bool7 = Boolean.valueOf("");
        boolean bool8 = Boolean.valueOf(null);
        System.out.println(bool1);
        System.out.println(bool2);
        System.out.println(bool3);
        System.out.println(bool4);
        System.out.println(bool5);
        System.out.println(bool6);
        System.out.println(bool7);
        System.out.println(bool8);
    }
    public static void main8(String[] args) {
        boolean bool1 = Boolean.TRUE;
        Boolean bool2 = Boolean.valueOf(bool1);
        System.out.println(bool2);
    }

    public static void main7(String[] args) {
        // 解析 true 字符串
        boolean bool1 = Boolean.parseBoolean("true");
        boolean bool2 = Boolean.parseBoolean("True");
        boolean bool3 = Boolean.parseBoolean("TRUE");
        // 解析不是 true 字符串
        boolean bool4 = Boolean.parseBoolean("False");
        boolean bool5 = Boolean.parseBoolean("1");
        boolean bool6 = Boolean.parseBoolean("Java");
        // 解析空字符串
        boolean bool7 = Boolean.parseBoolean("");
        boolean bool8 = Boolean.parseBoolean(null);
        System.out.println(bool1);
        System.out.println(bool2);
        System.out.println(bool3);
        System.out.println(bool4);
        System.out.println(bool5);
        System.out.println(bool6);
        System.out.println(bool7);
        System.out.println(bool8);
    }

    public static void main5(String[] args) {
        Boolean bool1 = Boolean.TRUE;
        Boolean bool2 = new Boolean(true);
        Boolean bool3 = new Boolean("false");
        boolean res1 = bool1.equals(bool2);
        System.out.println(res1);
        boolean res2 = bool2.equals(bool3);
        System.out.println(res2);
        System.out.println(bool1 == bool2);
        System.out.println(bool1.equals(null));
        System.out.println(bool3.equals(null));
    }

    public static void main4(String[] args) {
        Boolean bool = new Boolean(true);
        Boolean bool2 = new Boolean(false);
        Boolean bool3 = Boolean.TRUE;
        int res1 = bool.compareTo(bool2);
        int res2 = bool2.compareTo(bool3);
        int res3 = bool.compareTo(bool3);
        System.out.println(res1);
        System.out.println(res2);
        System.out.println(res3);
        int i = bool2.compareTo(null);
    }
    public static void main3(String[] args) {
        Boolean myTrue = Boolean.TRUE;
        Boolean myFalse = Boolean.FALSE;

        boolean primitiveTrue = true;
        boolean primitiveFalse = false;

        // 使用常量
        if (myTrue == primitiveTrue) {
            System.out.println("myTrue is true");
        }

        if (myFalse == primitiveFalse) {
            System.out.println("myFalse is false");
        }
    }

    public static void main2(String[] args) {
        Boolean aTrue = Boolean.TRUE;
        Boolean aFalse = Boolean.FALSE;
        Class<Boolean> type = Boolean.TYPE;
        System.out.println(aTrue);
        System.out.println(aFalse);
        System.out.println(type);
    }
    public static void main1(String[] args) {
        Boolean bool = new Boolean(true);
        Boolean bool2 = new Boolean(false);
        Boolean bool3 = new Boolean("true");
        Boolean bool4 = new Boolean("True");
        Boolean bool5 = new Boolean("1");
        Boolean bool7 = new Boolean("java");
        Boolean bool6 = new Boolean(null);
        System.out.println(bool);
        System.out.println(bool2);
        System.out.println(bool3);
        System.out.println(bool4);
        System.out.println(bool5);
        System.out.println(bool6);
        System.out.println(bool7);
    }
}
